import unittest
from common.base import get_driver
from page.browser1_page import Browser1Page
from page.browser2_page import Browser2Page


class Browser(unittest.TestCase):
    # setUpClass：所有test运行前执行一次
    @classmethod
    def setUpClass(cls) -> None:
        driver = get_driver() #并不是创建类
        driver.get('http://localhost:8080/ecshop/category.php?id=3')
        cls.index = Browser1Page(driver)
        cls.browser = Browser2Page(driver)
    def test1(self):
        # 诺基亚N85
        actual = self.browser.good1name()
        self.browser.good1()
        expect=self.index.goodname1()
        self.assertEqual(expect, actual, msg='断言失败')
    def test2(self):
        # 诺基亚E66
        actual = self.browser.good2name()
        self.browser.good2()
        expect = self.index.goodname2()
        self.assertEqual(expect, actual, msg='断言失败')
    def test3(self):
        # 飞利浦9@9v
        actual = self.browser.good3name()
        self.browser.good3()
        expect = self.index.goodname3()
        self.assertEqual(expect, actual, msg='断言失败')

    # tearDown：每个测试方法运行完后执行
    def tearDown(self) -> None:
         self.index.change()

    # tearDownClass：所有test运行完后执行一次
    @classmethod
    def tearDownClass(cls) -> None:
        cls.index.quit() # 继承了base的类





if __name__ == '__main__':
    unittest.main(verbosity=2)














